#!/bin/bash

echo "=== Testing ALTER TABLE and Complete CRUD Operations ==="

# Create test commands file for single interactive session
cat > /tmp/alter_test_commands << 'EOF'
CREATE DATABASE altertest;
USE altertest;
SHOW TABLES;
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));
DESCRIBE users;
INSERT INTO users VALUES (1, 'Alice');
INSERT INTO users VALUES (2, 'Bob');
SELECT * FROM users;
ALTER TABLE users ADD COLUMN email VARCHAR(100);
DESCRIBE users;
INSERT INTO users VALUES (3, 'Charlie', 'charlie@example.com');
SELECT * FROM users;
UPDATE users SET email = 'alice@example.com' WHERE id = 1;
SELECT * FROM users;
DELETE FROM users WHERE id = 2;
SELECT * FROM users;
ALTER TABLE users ADD COLUMN age INT DEFAULT 25;
DESCRIBE users;
INSERT INTO users VALUES (4, 'Diana', 'diana@example.com', 30);
SELECT * FROM users;
quit
EOF

echo "Testing ALTER TABLE and complete CRUD operations:"
echo "---"
cat /tmp/alter_test_commands
echo "---" 

# Run test commands in single interactive session
./bin/gu -h localhost -P 7777 -u admin -i < /tmp/alter_test_commands

# Cleanup
rm -f /tmp/alter_test_commands

echo "=== ALTER TABLE and CRUD Test Complete ==="